local Lua__yeguilai = fk.CreateSkill {

    name = "Lua__yeguilai",
  
    tags = { Skill.Compulsory, },
  
  }
  
  Fk:loadTranslationTable{
      
      ["Lua__yeguilai"] = "爷归来",
      [":Lua__yeguilai"] = "锁定技,游戏开始吋，你获得场上其他角色的所有牌，然后将牌堆里与你手牌相同的牌名的所有牌销毁。",

  }
  
  Lua__yeguilai:addEffect(fk.GameStart, {
      anim_type = "control",
      can_trigger = function(self, event, target, player, data)
          return player:hasSkill(Lua__yeguilai.name)
      end,
      
      on_use = function(self, event, target, player, data)
          local room = player.room
          room:notifySkillInvoked(player, Lua__yeguilai.name, "control")
          
          -- 获取场上其他角色的所有牌
          for _, p in ipairs(room:getOtherPlayers(player)) do
              -- 获取其他角色手牌
              local handcards = p:getCardIds("h")
              if #handcards > 0 then
                  room:obtainCard(player, handcards, false, fk.ReasonPrey)
              end
              
              -- 获取其他角色装备区牌
              local equips = p:getCardIds(Player.Equip)
              if #equips > 0 then
                  room:obtainCard(player, equips, false, fk.ReasonPrey)
              end
              
              -- 获取其他角色判定区牌
              local judges = p:getCardIds(Player.Judge)
              if #judges > 0 then
                  room:obtainCard(player, judges, false, fk.ReasonPrey)
              end
          end
          
          -- 销毁牌堆里与手牌相同牌名的牌
          local handcards = player:getCardIds()
          local handcard_names = {}
          
          -- 记录手牌中的牌名
          for _, id in ipairs(handcards) do
              local card = Fk:getCardById(id)
              local card_name = card.trueName
              handcard_names[card_name] = true
          end
          
          -- 检查牌堆中的牌
          local to_remove = {}
          for _, id in ipairs(Fk:getAllCardIds()) do
              local card = Fk:getCardById(id)
              local card_name = card.trueName
              
              -- 如果牌名在手牌中存在，且不是玩家手上的牌，则标记为需要销毁
              if handcard_names[card_name] and not table.contains(handcards, id) then
                  local place = room:getCardArea(id)
                  -- 只销毁在牌堆中的牌
                  if place == Card.DrawPile or place == Card.DiscardPile then
                      table.insert(to_remove, id)
                  end
              end
          end
          
          -- 销毁标记的牌
          if #to_remove > 0 then
            room:moveCardTo(to_remove, Card.Void, nil, fk.ReasonJustMove, Lua__yeguilai.name, nil, true, player.id)
          end
      end,
  })

  
  return Lua__yeguilai